home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-05-31 | 2.2 KB | 125 lines | [TEXT/CWIE] |
- unit MyNoForceQuit;
-
- interface
-
- procedure StartupNoForceQuit;
-
- implementation
-
- uses
- Types, Traps, OSUtils, Memory,
- MyStartup;
-
- {$PUSH}
- {$ALIGN MAC68K}
-
- type
- JumpThruRecord = packed record
- jump: UInt16;
- addr: UniversalProcPtr;
- end;
- JumpThruRecordPtr = ^JumpThruRecord;
-
- {$ALIGN RESET}
- {$POP}
-
- var
- jumpthru: JumpThruRecordPtr;
- oldsyserror: UniversalProcPtr;
-
- procedure AsmForceQuitStuff(oldaddr: UniversalProcPtr; var trapaddr: UniversalProcPtr); asm;
- begin
- lea NoForceQuit, a0
- move.l 4(sp), a1
- move.l a0, (a1)
- move.l 8(sp), a0
- lea savedaddr, a1
- move.l a0, (a1)
- rts
- NoForceQuit:
- cmp.w #20002,d0
- beq.s justreturn
- move.l savedaddr,a0
- jmp (a0)
- justreturn:
- rts
- savedaddr: ds.l 1
- end;
-
- function InitNoForceQuit(var msg: integer): OSStatus;
- begin
- {$unused(msg)}
- oldsyserror := NGetTrapAddress(_SysError, ToolTrap);
- jumpthru := JumpThruRecordPtr(NewPtrSys(SizeOf(JumpThruRecord)));
- jumpthru^.jump := $4EF9;
- AsmForceQuitStuff(oldsyserror, jumpthru^.addr);
- FlushDataCache;
- FlushInstructionCache;
- NSetTrapAddress(UniversalProcPtr(jumpthru), _SysError, ToolTrap);
- InitNoForceQuit := noErr;
- end;
-
- procedure FinishNoForceQuit;
- begin
- jumpthru^.addr := oldsyserror;
- FlushDataCache;
- FlushInstructionCache;
- end;
-
- procedure StartupNoForceQuit;
- begin
- SetStartup(InitNoForceQuit, nil, 0, FinishNoForceQuit);
- end;
-
- end.
- function MyGetTrapAddress (trapword: integer): UniversalProcPtr;
- begin
- MyGetTrapAddress := UniversalProcPtr(NGetTrapAddress(trapword, TrapType(TPbtst(trapword, 11))));
- end;
-
- procedure MySetTrapAddress (addr: UniversalProcPtr; trapword: integer);
- begin
- NSetTrapAddress(addr, trapword, TrapType(TPbtst(trapword, 11)));
- end;
-
- include 'sysequ.a'
- include 'traps.a'
- proc
- export AsmInitNoForceQuit, NoForceQuit
-
- ; procedure AsmInitNoForceQuit(sys6byte:Ptr; oldsyserror:Ptr);
- AsmInitNoForceQuit
- lea data,a1
- move.l 4(sp),0(a1)
- move.l 8(sp),a0
- move.l a0,4(a1)
- move.w #$4EF9,(a0)
- lea NoForceQuit,a1
- move.l a1,2(a0)
-
- _FlushDataCache
- _FlushInstructionCache
-
- move.l (sp)+,a0
- add.l #8,sp
- jmp (a0)
-
- ; D0.w = error
- NoForceQuit
- cmp.w #20002,d0
- beq.s justreturn
- move.l oldaddr,a0
- jmp (a0)
- justreturn
- rts
-
- data
- oldaddr ds.l 1
- sysptr ds.l 1
-
- endp
-
- end
-
- asm -wb "{active}"
-